**************************************************
* This program performs the additional analyses  *
* on institutional ownership after COW           *
* reported in section B.1.5                      *
**************************************************

	clear all
	global path "C:\cow"
	use "$path\inst.dta"
	set more off

	*Convert strings to numerics
	destring gvkey, gen(firm)	
	encode state, gen(lstateFE)
	encode incorp, gen(istateFE)

	*Set timeframe 
	drop if fyear < 1996 
	
	*Drop if missing industry
	rename sic sic4
	gen sic3 = floor(sic4/10)
	gen sic2 = floor(sic4/100)
	gen sic1 = floor(sic4/1000)
	drop if missing(sic4)
	*Drop utilities
	drop if sic4 >= 4900 & sic4 <= 4999
	*Drop financials
	drop if sic4 >= 6000 & sic4 <= 6999
	*Drop public administration/non-classifiable firms
	drop if sic4 >= 9000 & sic4 <= 9999


	*Drop if missing headquarter state
	drop if missing(state)
	*Drop if missing state of incorporation
	drop if missing(incorp)
	*Drop if not incorporated in U.S. state
	drop if inlist(incorp, "AS", "INTL", "PR", "TT", "VI")


	local statelist "DE OK MO KS TX NV NJ MD WA"
	gen treatment = 0
	foreach state of local statelist {
			replace treatment = 1 if incorp == "`state'"
	}


	*Create macros for date when law was passed
		local DE_cow = date("01Jul2000","DMY")
		local OK_cow = date("01Nov2001","DMY")
		local MO_cow = date("01Oct2003","DMY")
		local KS_cow = date("01Jan2005","DMY")
		local TX_cow = date("01Jan2006","DMY")
		local NV_cow = date("01Oct2007","DMY")
		local NJ_cow = date("11Mar2011","DMY")
		local MD_cow = date("01Oct2014","DMY")
		local WA_cow = date("01Jan2016","DMY")
		
		* adjust calendar year of fyeendt to be next year if fyenddt month < cow law date
		gen ayear = year(datadate)
		local statelist "DE OK MO KS TX NV NJ MD WA"
		foreach state of local statelist {
				replace ayear = year(datadate)-1 if incorp == "`state'" & month(datadate) < month(``state'_cow')
				}

		*cow: indicator equal to one if firm is incorporated in a state that has passed a COW law
		gen cow = 0
		local statelist "DE OK MO KS TX NV NJ MD WA"
		foreach state of local statelist {
				replace cow = 1 if incorp == "`state'" & ayear >= year(``state'_cow')
				}

	
		
			
	gen ln_mveq_rd=log(1+mveq_rd)
	drop if mveq_rd<0

	gen smallcap=0
	replace smallcap=1 if mveq_rd<3000
	gen cow_smallcap=cow*smallcap 

	
*************************
* Regression equation 5 *	
*************************
	
	reghdfe propown cow cow_smallcap smallcap , absorb(cusip lstate#fyear sic3#fyear) vce(cluster istate) 
	test cow + cow_smallcap =0

